<!--
 * @Author: gongjiuhui
 * @Date: 2022-04-21 16:34:36
 * @LastEditTime: 2022-05-13 11:47:34
 * @LastEditors: gong.jiuhui you@example.com
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \jk_one-stop_cloud_mobile_v1.0\src\views\apply\purchaseDetail.vue
-->
<template>
  <div class="receiptDetail">
    <Navbar @eventGetHeight="getHeight" :appTitle="title" />
    <!--头部-->
    <div id="headdd" class="d-head">
      <div class="content">
        <div class="left">
          <div class="title">
            {{$route.query.title}}
          </div>
          <div class="row">
            <span class="r-label">合同单号：</span>
            <span class="r-column">{{
              workOrderInfo.contractIdText || "--"
            }}</span>
          </div>
          <div class="row">
            <span class="r-label">签收人：</span>
            <span class="r-column">{{
              workOrderInfo.createByText || "--"
            }}</span>
          </div>
          <!-- <div class="status" v-if="workOrderInfo.statusText">{{ workOrderInfo.statusText }}</div> -->
        </div>
        <!-- ids="ERP_PURCHASE_SIGN_ORDER" -->
        <imgStatus
          :flowStatus="workOrderInfo.flowStatus"
        ></imgStatus>
        
      </div>
    </div>

    <!-- taps-->
    <!--锚点选项卡-->
    <van-tabs v-model="active" scrollspy sticky :offset-top="runingHeight">
       <!--基本信息 -->
      <van-tab title="基本信息">
        <div class="otherTaps" :style="calssDD">
          <div class="title">
            <span class="icon"></span>
            <span class="content">基本信息</span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label">签订时间：</span>
              <span class="r-column">{{ workOrderInfo.createTime || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">签收商品种类：</span>
              <span class="r-column">{{ workOrderInfo.receiptGoodsType || "--"}}</span>
            </div>
           <div class="row">
              <span class="r-label">总签收件数：</span>
              <span class="r-column">{{ workOrderInfo.receiptNum || "--"}}</span>
            </div>
             <div class="row">
              <span class="r-label">签收备注：</span>
              <span class="r-column">{{ workOrderInfo.remark || "--"}}</span>
            </div>
            <div class="row">
              <span class="r-label">签收图片：</span>
              <span class="r-column">
                <span v-if="workOrderInfo.attachment==''">--</span>
                <upload
                  class="fileclass"
                  iconType="fj"
                  @fileChange="fileChange"
                  :fileIds="workOrderInfo.attachment"
                  :showUpload="false"
                ></upload>
              </span>
            </div>
          </div>
        </div>
      </van-tab>
      <!--基本信息 -->
      <van-tab title="签收明细">
        <div
          class="otherTaps"
          v-for="(
            item, index
          ) in workOrderInfo.erpPurchaseSignOrderItemVoList"
          :key="index"
         
        >
          <div class="title">
            <span class="icon"></span>
            <span class="content">签收明细<span v-if="workOrderInfo.erpPurchaseSignOrderItemVoList.length!=1">{{ index + 1 }}</span></span>
          </div>
          <div class="content">
            <div class="row">
              <span class="r-label salea">物品编号：</span>
              <span class="r-column">{{ item.goodsCode }} </span>
            </div>
            <div class="row">
              <span class="r-label salea">物品名称：</span>
              <span class="r-column">{{ item.goodsName }}</span>
            </div>
            <div class="row">
              <span class="r-label salea">规格：</span>
              <span class="r-column">{{ item.spec }}</span>
            </div>
            <div class="row">
              <span class="r-label salea">本次签收数量：</span>
              <span class="r-column">{{ item.signNum }}{{ item.unit }}</span>
            </div>
          </div>
        </div>
      </van-tab>
     
     
      <!--审批流程 -->
      <van-tab title="审批流程" v-if="workOrderInfo.flowInstId">
        <div class="otherTaps" :style="bottomHeight">
          <div class="title">
            <span class="icon"></span>
            <span class="content">审批流程</span>
          </div>
          <!--ids="ERP_PURCHASE_SIGN_ORDER" -->
          <Examine
            v-if="workOrderInfo.flowInstId"
            type="2"
            :id="workOrderInfo.flowInstId"
            ref="examine"
            :showTitle="false"
          />
        </div>
      </van-tab>
    </van-tabs>

    <!--提交按钮 -->
    <div
      class="search-bottom"
      v-if="
        $route.query.applyType == 'waiterDeal' &&
        workOrderInfo.flowStatus == 'RUNNING'
      "
    >
      <span class="btncancel" @click="cancel">拒绝</span>
      <span class="btnconfirm" @click="confirm">同意</span>
    </div>
  </div>
</template>

<script>
import { erpPurchaseSignOrderQueryById } from "@/api/mobile.js";
import Navbar from "@/components/navBar/navBar_right";
import upload from "@/components/upload/upload";
import Examine from "@/components/examine";
import { numFormat } from "@/utils/util";
import imgStatus from "@/components/imgStatus/imgStatus";
import { getEnableOne } from "@/api/api";
export default {
  name: "recordDetail",
  components: { Navbar, upload, Examine, imgStatus },
  data() {
    return {
      topmenuHeiht:"",
      showFLow:true,
      bodyHeight:"",
      runingHeight: "",
      bottomHeight:"padding-bottom:1.5rem",
      calssDD: "",
      numFormat,
      parentId: "",
      tableData: [],
      workOrderInfo: {},
      reasonArr: [], //不合格原因
      title: this.$route.meta.title,
      tabList: [
        { name: "发货记录", value: "1" },
        { name: "开票记录", value: "2" },
        { name: "收款记录", value: "2" },
      ],
      active: 0,
      fileIds: "1514159656052879361,1514159725032402946",
    };
  },
  computed: {},
  mounted() {
  },
  created() {
    this.parentId = this.$route.query.id;
    this.getDetail();
    // this.isShowFLow();
  },
  methods: {
      isShowFLow(){
       getEnableOne({ id: "ERP_PURCHASE_SIGN_ORDER", type: "add" }).then((res) => {
        //  console.log(res)
        //  alert(res.result)
        if (res.result && res.result == "false") {
          this.showFLow = false;
          
          
        } else {
          this.showFLow = true;
          //  alert("222")
        }
         this.initHeight(this.topmenuHeiht)
      });   
     },
     getHeight(data) {
       let topdd=this.GLOBAL.currentEnvironment ? '0' : '46'
      this.bodyHeight=document.body.clientHeight;//屏幕高度
      this.runingHeight =data+document.getElementById("headdd").offsetHeight-5;
      this.calssDD = "margin-top:" + (this.runingHeight - topdd) + "px";
      this.isShowFLow();
      // if(this.bodyHeight>=736){
      //   this.bottomHeight="padding-bottom:2rem";
      // }
      // if(this.bodyHeight>=812){
      //    this.bottomHeight="padding-bottom:2.5rem";
      // }
      // if(this.bodyHeight>=844){
      //    this.bottomHeight="padding-bottom:2.8rem";
      // }
      // if(this.bodyHeight>=896){
      //    this.bottomHeight="padding-bottom:3rem";
      // }
    
        
    },
    initHeight(data){
      // alert(data)
      console.log(data,'计算高度')
      this.bodyHeight=document.body.clientHeight;//屏幕高度
       if(this.bodyHeight>=667){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:1.5rem";
        }else{
           this.bottomHeight="padding-bottom:2.5rem";
          //  alert("ddddddd")

        }
      }
      if(this.bodyHeight>=736){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2rem";
        }else{
           this.bottomHeight="padding-bottom:3rem";

        }
        
      }
      if(this.bodyHeight>=812){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2.5rem";
        }else{
          this.bottomHeight="padding-bottom:3.5rem";
        }
         
      }
      if(this.bodyHeight>=844){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:2.8rem";
        }else{
          this.bottomHeight="padding-bottom:3.8rem";
        }
         
      }
      if(this.bodyHeight>=896){
        if(this.showFLow){
           this.bottomHeight="padding-bottom:3rem";
        }else{
           this.bottomHeight="padding-bottom:4rem";
        }
      }
     
   
    },
    cancel() {
      // approveType 1:同意 0:拒绝
      this.$router.push({
        path: "/approval",
        query: { approveType: 0, taskId: this.$route.query.taskId },
      });
    },
    confirm() {
      this.$router.push({
        path: "/approval",
        query: { approveType: 1, taskId: this.$route.query.taskId },
      });
    },
    fileChange(ids) {
      // console.log(ids);
      this.formData.attachment = ids;
    },
    getDetail() {
      erpPurchaseSignOrderQueryById({ id: this.parentId }).then((res) => {
        if (res.success) {
          if (res.result) {
            this.workOrderInfo = res.result;
          }
        } else {
          this.$toast(res.message);
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.receiptDetail {
  height: 100vh;
  overflow-y: scroll;
  background: #ffffff;
  // background: green;
  .d-head {
    position: fixed;
    width: 100%;
    padding: 0.16rem 0.16rem 0.16rem 0.16rem;
    background: #ffffff;
    z-index: 999;
     .status {
  display: inline-block;
  margin-top: 0.16rem;
  padding: 0.03rem 0.08rem;
  background: #edf6ff;
  border-radius: 0.02rem;
  font-size: 0.11rem;
  font-family: PingFang SC;
  font-weight: 400;
  color: #3774ac;
}  
    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      .left {
        width: 2.8rem;
        // border: 1px solid red;
        .title {
          font-size: 0.16rem;
          font-family: PingFang SC;
          font-weight: 500;
          color: #191f25;
          line-height: 0.22rem;

          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          -o-text-overflow: ellipsis;
        }
        .row {
          font-size: 0.14rem;
          font-family: PingFang SC;
          font-weight: 400;
          color: #888888;
          margin-top: 0.16rem;
          display: flex;
          
          .r-label {
            // width: 0.8rem;
            color: #888888;
            // border: 1px solid red;
          }
          .r-column {
            width: 2rem;
            color: #191f25;
             overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            -o-text-overflow: ellipsis;
          }
        }
      }
      .right {
        // border: 1px solid red;
        width: 0.6rem;
        .rightImg {
          display: block;
          width: 0.55rem;
          height: 0.55rem;
          //   margin-left: 0.45rem;
          // border: 1px solid blue;
        }
      }
    }
  }

  .otherTaps {
    background: #ffffff;
    padding: 0.16rem;
    border-top:0.1rem solid rgb(245, 245, 245);
    .title {
      padding-bottom: 0.1rem;
      border-bottom: 1px solid #eeeeee;
      .icon {
        display: inline-block;
        width: 0.03rem;
        height: 0.14rem;
        background: #1890ff;
      }
      .content {
        width: 0.63rem;
        height: 0.16rem;
        font-size: 0.16rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #191f25;
        line-height: 0.22rem;
        margin-left: 0.1rem;
      }
    }
    .content {
      .row {
        font-size: 0.14rem;
        font-family: PingFang SC;
        font-weight: 400;
        margin-top: 0.16rem;
        display: flex;
        .r-label {
          color: #888888;
          // width: 1.2rem;
        }
        .salea{
          //  width: 1.7rem !important;
        }
        .r-column {
          //   display: block;
          color: #191f25;
          // width: 2.5rem;
          // width: 100%;
          white-space: normal;
          word-break: break-all;
          word-wrap: break-word;
          // border: 1px solid red;
          //   border: 1px solid red;
          //    width: 1rem;
        }
      }
      .fhrow {
        display: flex;
        .fhImg {
          width: 0.55rem;
          height: 0.55rem;
          border-radius: 0.1rem;
        }
        .rt-column {
          width: 2.55rem;
          //   height: 2.55rem;
          margin-left: 0.2rem;
          .rt-title {
            font-size: 0.16rem;
            font-family: PingFang SC;
            font-weight: 500;
            color: #191f25;
            margin-bottom: 0.16rem;
          }
          .rt-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.23rem;
            .column {
              //    border: 1px solid red;
              width: 1.5rem;
              .column-t {
                font-size: 0.14rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #888888;
                display: block;
                width: 100%;
                margin-bottom: 0.03rem;
              }
              .column-c {
                font-size: 0.16rem;
                font-family: PingFang SC;
                font-weight: 400;
                color: #191f25;
                display: block;
                width: 100%;
              }
            }
          }
        }
      }
    }
  }
  .search-bottom {
    height: 0.5rem;
    width: 100%;
    background: #ffffff;
    // background: red;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    bottom: 0px;
    padding: 0.11rem;
    .btnconfirm {
      width: 1.72rem;
      height: 0.39rem;
      background: #1890ff;
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
    .btncancel {
      width: 1.72rem;
      height: 0.39rem;
      background: #f6f6f6;
      border: 0.01px solid rgba(25, 31, 37, 0.12);
      border-radius: 0rem;
      text-align: center;
      line-height: 0.39rem;
    }
  }
}
</style>
<style>
.van-tabs__line {
  background-color: #1890ff;
}
.van-tab--active {
  color: #1890ff;
}
</style>